package com.xqb.modules.service.impl;

import java.util.List;
import com.xqb.common.utils.DateUtils;
import com.xqb.common.utils.SecurityUtils;
import com.xqb.modules.domain.po.MktPromotion;
import com.xqb.modules.mapper.MktPromotionMapper;
import com.xqb.modules.service.IMktPromotionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 促销活动Service业务层处理
 * 
 * @author xqb
 * @date 2024-10-15
 */
@Service
public class MktPromotionServiceImpl implements IMktPromotionService
{
    @Autowired
    private MktPromotionMapper mktPromotionMapper;

    /**
     * 查询促销活动
     * 
     * @param id 促销活动主键
     * @return 促销活动
     */
    @Override
    public MktPromotion selectMktPromotionById(Long id)
    {
        return mktPromotionMapper.selectMktPromotionById(id);
    }

    /**
     * 查询促销活动列表
     * 
     * @param mktPromotion 促销活动
     * @return 促销活动
     */
    @Override
    public List<MktPromotion> selectMktPromotionList(MktPromotion mktPromotion)
    {
        return mktPromotionMapper.selectMktPromotionList(mktPromotion);
    }

    /**
     * 新增促销活动
     * 
     * @param mktPromotion 促销活动
     * @return 结果
     */
    @Override
    public int insertMktPromotion(MktPromotion mktPromotion)
    {
        mktPromotion.setCreateTime(DateUtils.getNowDate());
        mktPromotion.setInsId(SecurityUtils.getLoginUser().getUser().getInsId());
        return mktPromotionMapper.insertMktPromotion(mktPromotion);
    }

    /**
     * 修改促销活动
     * 
     * @param mktPromotion 促销活动
     * @return 结果
     */
    @Override
    public int updateMktPromotion(MktPromotion mktPromotion)
    {
        mktPromotion.setUpdateTime(DateUtils.getNowDate());
        return mktPromotionMapper.updateMktPromotion(mktPromotion);
    }

    /**
     * 批量删除促销活动
     * 
     * @param ids 需要删除的促销活动主键
     * @return 结果
     */
    @Override
    public int deleteMktPromotionByIds(Long[] ids)
    {
        return mktPromotionMapper.deleteMktPromotionByIds(ids);
    }

    /**
     * 删除促销活动信息
     * 
     * @param id 促销活动主键
     * @return 结果
     */
    @Override
    public int deleteMktPromotionById(Long id)
    {
        return mktPromotionMapper.deleteMktPromotionById(id);
    }
}
